let app = getApp();
Component({
    /**
     * 组件的属性列表
     */
    properties: {
            value: {
                type: Number,
                default: 0
            },
            tabs: {
                type: Array,
                default: function() {
                    return [];
                }
            },
            bgColor: {
                type: String,
                default: "#fff"
            },
            padding: {
                type: String,
                default: "0"
            },
            color: {
                type: String,
                default: "#333"
            },
            activeColor: {
                type: String,
                default: "#2979ff"
            },
            fontSize: {
                type: String,
                default: "28rpx"
            },
            activeFontSize: {
                type: String,
                default: "32rpx"
            },
            bold: {
                type: Boolean,
                default: !0
            },
            scroll: {
                type: Boolean,
                default: !0
            },
            height: {
                type: String,
                default: "70rpx"
            },
            lineColor: {
                type: String,
                default: "#2979ff"
            },
            lineHeight: {
                type: String,
                default: "10rpx"
            },
            lineScale: {
                type: Number,
                default: .2
            },
            lineRadius: {
                type: String,
                default: "10rpx"
            },
            pills: {
                type: Boolean,
                default: !1
            },
            pillsColor: {
                type: String,
                default: "#2979ff"
            },
            pillsBorderRadius: {
                type: String,
                default: "10rpx"
            },
            field: {
                type: String,
                default: ""
            },
            fixed: {
                type: Boolean,
                default: !1
            },
            paddingItem: {
                type: String,
                default: "0 40rpx"
            },
            lineAnimation: {
                type: Boolean,
                default: !0
            }
    },

    /**
     * 组件的初始数据
     */
    data: {
        tabs:['拼油油',"阶梯价"],
        lineAnimation:true,

        elId: "",
        lineWidth: 30,
        currentWidth: 0,
        lineLeft:0,
        pillsLeft: 0,
        scrollLeft: 0,
        containerWidth: 0,
        current: 0,
        fixed:1,
        distance:93.75-15

    },
    created() {

    },
    attached: function () {

    },
    /**
     * 组件的方法列表
     */
    methods: {
        changeNav(e){
            if( this.data.current == e.currentTarget.dataset.index  ) return
            if(e.currentTarget.dataset.index == 0){
                this.data.current =  e.currentTarget.dataset.index
                this.data.distance =  this.data.distance - 93.75 -93.75
                this.setData({
                    current:this.data.current,
                    distance: this.data.distance
                })
            }
            if(e.currentTarget.dataset.index == 1){
                this.data.current =  e.currentTarget.dataset.index
                this.data.distance =  this.data.distance + 93.75 +93.75
                this.setData({
                    current:this.data.current,
                    distance: this.data.distance
                })
            }

        }
    }
})
